﻿
package extremefx.browser {
	import extremefx.extensions.isNullOrEmpty;

	import flash.display.DisplayObject;
	import flash.display.LoaderInfo;

	/**
	 * @author Marcelo Volmaro
	 */
	public final class FlashVars {
		private static var _data:Object;
		 
		public static function init(pRoot:DisplayObject):void {
			if (pRoot.root) pRoot = pRoot.root;
			_data = LoaderInfo(pRoot.loaderInfo).parameters;
		}
		
		static public function getValue(pKey:String, pDefaultValue:String = null):String {
			if (isNullOrEmpty(pKey) || !(pKey in _data)) return pDefaultValue;
			
			return _data[pKey];
		}
	}
}
